package lianxi4;

public class Test {
    public static void main(String[] args) {
        CPU cpu = new CPU();//创建CPU对象cpu
        cpu.speed = 2200;//设置速度为2200
        HardDisk disk = new HardDisk();//创建对象disk
        disk.amount = 200;//amount设置为200
        PC pc = new PC();//创建一个PC对象pc
        pc.setCPU(cpu);//方法调用实参是cpu
        pc.setHardDisk(disk);//方法调用实参是disk
        pc.show();
    }
}

class PC{
CPU cpu;
HardDisk HD;
public void setCPU(CPU c) {
    cpu=c;
}
public void setHardDisk(HardDisk h) {
    HD=h;
}
public void show(){
    System.out.println("CPU的速度:"+cpu.getSpeed()+"硬盘的容量:"+HD.getAmount());
}
}

class CPU {
int speed;

    public void setSpeed(int m) {
        this.speed = m;
    }
    public int getSpeed() {
        return speed;
    }
}

class HardDisk {
int amount;
public void setAmount(int m) {
    this.amount = m;
}
public int getAmount() {
    return amount;
}
}